<?php

namespace App\Admin\Controllers;

use App;

use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;
use App\Models\UserTag;
use UserTagService;

class UserTagController extends Controller
{
    use ModelForm;

    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header(trans('backend.testing_user_tag.title.list'));
            $content->body($this->grid());
        });
    }

    /**
     * Edit interface.
     *
     * @param $id
     * @return Content
     */
    public function edit($id)
    {
        return Admin::content(function (Content $content) use ($id) {
            $content->header(trans('backend.testing_user_tag.title.edit'));
            $content->body($this->form()->edit($id));
        });
    }

    /**
     * Create interface.
     *
     * @return Content
     */
    public function create()
    {
        return Admin::content(function (Content $content) {
            $content->header(trans('backend.testing_user_tag.title.add'));
            $content->body($this->form());
        });
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Admin::grid(UserTag::class, function (Grid $grid) {
            $grid->uid(trans('backend.testing_user_tag.column.uid'));
			$grid->tid(trans('backend.testing_user_tag.column.tid'));
			$grid->tag(trans('backend.testing_user_tag.column.tag'));
			
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Admin::form(UserTag::class, function (Form $form) {
            $form->text('uid',trans('backend.testing_user_tag.column.uid'));
			$form->text('tid',trans('backend.testing_user_tag.column.tid'));
			$form->text('tag',trans('backend.testing_user_tag.column.tag'));
			
        });
    }
}
